import numpy as np
import pylab
import cv2

# 读取图片
sky = cv2.imread('train_image/sky.png')
# 转换
sk1 =  cv2.cvtColor(sky, cv2.COLOR_BGR2RGB)

pylab.subplot(1,2,1)
pylab.imshow(sk1)
pylab.show()


lower_blue = np.array([15, 60, 60])
upper_blue = np.array([130, 255, 255]) #去除云
pylab.subplot(1,2,2)
hsv=cv2.cvtColor(sky,cv2.COLOR_BGR2HSV)
mask=cv2.inRange(hsv,lower_blue,upper_blue)
res=cv2.bitwise_and(sky,sky,mask=mask)

cv2.imwrite("train_image/res.jpg", res)
res = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
pylab.imshow(res)
pylab.show()